from sys import stdin
from sys import exit

class Interpreter:
	def __init__(self):
		self.stack = []
		self.s = stdin.readlines()
		self.errormsg = ""
	
	def interpret(self):

		if (len(self.s) < 2):
			self.errormsg = "No input"
			self.error()

		for line in self.s:

			if line[0] == 'P':
				if line[0:4] == "PUSH":
					num = line[5:len(line)]
					for i in range (0, len(num) -1):
						if not (num[i].isdigit()):
							self.errormsg = "Invalid operation"
							self.error()
					self.stack.append(int(num))
				elif line[0:5] == "PRINT":
					print self.stack.pop()
				else:
					self.errormsg = "WTF"
					self.error()

			elif line[0] == 'A':
				if (line[0:3] == "ADD"):
					if len(self.stack) > 1:
						self.stack.append(self.stack.pop() + self.stack.pop())
					else:
						self.errormsg = "ADD"
						self.error()
				else:
					self.error()

			elif line[0] == 'M':
				if (line[0:4] == "MULT"):
					if len(self.stack) > 1:
						self.stack.append(self.stack.pop() * self.stack.pop())
					else:
						self.error()
				else:
					self.error()

			elif line[0] == 'E':
				if (line[0:6] == "ERROR"):
					self.errormsg = "Syntax error"
					self.error()
				else:
					self.errormsg = "ERROR"
					self.error()

	
	def error(self):
		print "Error for operator: " + self.errormsg
		exit()

	def main(self):		
		while self.s != "PRINT":
			self.interpret()
		print self.stack.pop()
		

intr = Interpreter()
intr.interpret()